package ru.jexp.rcp.supply.actions;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IWorkbenchWindow;

import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardClient;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardD18Pattern;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardDetail;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardMark;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardMaterial;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardNd;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardPf;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardPki;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardSe;
import ru.jexp.rcp.supply.actions.wizards.ActionNewWizardSupplier;
import ru.jexp.rcp.supply.beans.account.NewWizardAccount;
import ru.jexp.rcp.supply.beans.nakl.NewWizardNakl;
import ru.jexp.rcp.supply.beans.project.NewWizardProj;
import ru.jexp.rcp.supply.beans.zs.wizard.NewWizardZs;
import ru.jexp.rcp.supply.beans.zt.NewWizardZt;

public class ActionMenuCreatorWizard extends ActionMenuCreator
{

	public ActionMenuCreatorWizard(IWorkbenchWindow window)
	{
		addAction(createActionUseWizard(window, ActionNewWizardDetail.ID));
		addAction(createActionUseWizard(window, NewWizardZs.ID));
		addAction(createActionUseWizard(window, NewWizardZt.ID));
		addAction(createActionUseWizard(window, ActionNewWizardClient.ID));
		addAction(createActionUseWizard(window, ActionNewWizardMark.ID));
		addAction(createActionUseWizard(window, ActionNewWizardMaterial.ID));
		addAction(createActionUseWizard(window, ActionNewWizardNd.ID));
		addAction(createActionUseWizard(window, ActionNewWizardPf.ID));
		addAction(createActionUseWizard(window, ActionNewWizardPki.ID));
		addAction(createActionUseWizard(window, ActionNewWizardSupplier.ID));
		addAction(createActionUseWizard(window, NewWizardProj.ID));
		addAction(createActionUseWizard(window, ActionNewWizardSe.ID));
		addAction(createActionUseWizard(window, NewWizardAccount.ID));
		addAction(createActionUseWizard(window, NewWizardNakl.ID));
		addAction(createActionUseWizard(window, ActionNewWizardD18Pattern.ID));
	}

	private IAction createActionUseWizard(IWorkbenchWindow window, String id)
	{
		IActionNewWizard wizard;
		try
		{
			wizard = (IActionNewWizard) window.getWorkbench().getNewWizardRegistry().findWizard(id).createWizard();
			wizard.init(window);
		}
		catch (CoreException e)
		{
			e.printStackTrace();
			throw new RuntimeException();
		}
		return wizard.getAction();
	}
}
